package com.own.component.store.redis.util;

import com.own.component.store.core.util.base.BaseLockMethod;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RedissonClient;

import java.util.concurrent.locks.Lock;

/**
 * RedisLockStoreUtil
 *
 * @author chenxueli
 * @date 2022-06-15 03:14:15
 */
@Slf4j
public class RedisLockStoreUtil implements BaseLockMethod {

    private final RedissonClient redissonClient;

    public RedisLockStoreUtil(RedissonClient redissonClient) {
        this.redissonClient = redissonClient;
    }

    /**
     * 获取锁对象
     *
     * @param key 锁的key
     * @return 锁
     */
    @Override
    public Lock getLock(String key) {
        return redissonClient.getLock(key);
    }

}
